package com.lzh.chatnote.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 *  1是 2否
 */
@AllArgsConstructor
@Getter
public enum CursorEnum {
    ASC("ASC", "是"),
    DESC("DESC", "否"),
    ;
    private final String value;
    private final String describe;

    private static final Map<String, CursorEnum> cache;

    static {
        cache = Arrays.stream(CursorEnum.values()).collect(Collectors.toMap(CursorEnum::getValue, Function.identity()));
    }

    public static CursorEnum of(String value) {
        return cache.get(value);
    }
}
